package zuoye;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class Map1 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Map map = new HashMap();
		map.put("Zouenceng", "3");
		map.put("Shenyu", "4");
		map.put("Lucy", "5");
		map.put("Lily", "4");
		map.put("Han MeiMei", "5");
		map.put("Jim", "3");
		String key = "Shenyu";
		String value = null;
		if (map.containsKey(key))
		{
			value = (String) map.get(key);
			System.out.println("Use key:" + key + " find value:" + value);
		}
		else
		{
			System.out.println("Does not contain key:" + key);
		}
		
		 key = "Zouenceng";
		
		if (map.containsKey(key))
		{
			value = (String) map.get(key);
			System.out.println("Use key:" + key + " find value:" + value);
		}
		else
		{
			System.out.println("Does not contain key:" + key);
		}
		key = "Tom";
		if (map.containsKey(key))
		{
			value = (String) map.get(key);
			System.out.println("Use key:" + key + " find value:" + value);
		}
		else
		{
			System.out.println("Does not contain key:" + key);
			value = (String) map.get(key);
	}
	
				Iterator it = map.entrySet().iterator();
				Map.Entry entry = (Map.Entry) it.next();
		        key=(String) entry.getKey();
		        value=(String) entry.getValue();
		        System.out.println("Use iterator to get the  entry is Key :"+key+"  Value :"+value);
		        
		       
				entry = (Map.Entry) it.next();
		        key=(String) entry.getKey();
		        value=(String) entry.getValue();
		        System.out.println("Use iterator to get the  entry is Key :"+key+"  Value :"+value);
		        entry = (Map.Entry) it.next();
		        key=(String) entry.getKey();
		        value=(String) entry.getValue();
		        System.out.println("Use iterator to get the  entry is Key :"+key+"  Value :"+value);
		        entry = (Map.Entry) it.next();
		        key=(String) entry.getKey();
		        value=(String) entry.getValue();
		        System.out.println("Use iterator to get the  entry is Key :"+key+"  Value :"+value);
		        entry = (Map.Entry) it.next();
		        key=(String) entry.getKey();
		        value=(String) entry.getValue();
		        System.out.println("Use iterator to get the  entry is Key :"+key+"  Value :"+value);
		        entry = (Map.Entry) it.next();
		        key=(String) entry.getKey();
		        value=(String) entry.getValue();
		        System.out.println("Use iterator to get the  entry is Key :"+key+"  Value :"+value);
		        
		        System.out.println();
		         
	}
	}
